<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
      <!--始发站-->
      <el-form-item label="始发站" prop="start">
        <el-select v-model="queryParams.start" filterable remote clearable placeholder="请输入始发站"
          :remote-method="remoteMethod" :loading="loading" size="small" style="width: 200px" allow-create>
          <el-option v-for="item in stationOptions" :key="item.uniqueId" :label="item.label" :value="item.value"
            style="width: 300px">
          </el-option>
        </el-select>
      </el-form-item>
      <!--终点站-->
      <el-form-item label="终点站" prop="end">
        <el-select v-model="queryParams.end" filterable remote clearable placeholder="请输入终点站"
          :remote-method="remoteMethod" :loading="loading" size="small" style="width: 200px" allow-create>
          <el-option v-for="item in stationOptions" :key="item.uniqueId" :label="item.label" :value="item.value"
            style="width: 300px">
          </el-option>
        </el-select>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">查找</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button type="primary" plain icon="el-icon-plus" size="mini" @click="handleAdd"
          v-hasPermi="['base:train:add']">新增</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button type="success" plain icon="el-icon-edit" size="mini" :disabled="single" @click="handleUpdate"
          v-hasPermi="['base:train:edit']">修改</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button type="danger" plain icon="el-icon-delete" size="mini" :disabled="multiple" @click="handleDelete"
          v-hasPermi="['base:train:remove']">删除</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button type="warning" plain icon="el-icon-download" size="mini" @click="handleExport"
          v-hasPermi="['base:train:export']">导出</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button type="warning" plain icon="el-icon-upload" size="mini" @click="handleImport"
          v-hasPermi="['base:train:add']">导入</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button type="danger" plain icon="el-icon-delete" size="mini" @click="handleClear"
                   v-hasPermi="['base:train:remove']">清空数据</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button v-if="showImportError" type="danger" plain icon="el-icon-download" size="mini"
          @click="handleExportErrorData">导出错误数据</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button v-if="showImportError" type="danger" plain icon="el-icon-document-copy" size="mini"
          @click="handleCopyErrorData">复制到剪贴板</el-button>
      </el-col>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <el-table v-loading="loading" :data="trainList" :row-style="{ height: '60px' }"
      @selection-change="handleSelectionChange">
      <el-table-column show-overflow-tooltip type="selection" width="55" align="center" />
      <el-table-column show-overflow-tooltip label="id" type="index" align="center" prop="id" />
      <el-table-column show-overflow-tooltip label="车次编号" align="center" prop="code" />
      <el-table-column show-overflow-tooltip label="车次类型" align="center" prop="type">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.type" :value="scope.row.type" />
        </template>
      </el-table-column>
      <el-table-column show-overflow-tooltip label="始发站" align="center" prop="start" />
      <el-table-column show-overflow-tooltip label="始发站拼音" align="center" prop="startPinyin" />
      <el-table-column show-overflow-tooltip label="出发时间" align="center" prop="startTime" width="150" />
      <el-table-column show-overflow-tooltip label="终点站" align="center" prop="end" />
      <el-table-column show-overflow-tooltip label="终点站拼音" align="center" prop="endPinyin" />
      <el-table-column show-overflow-tooltip label="到站时间" align="center" prop="endTime" width="150" />
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width" width="180">
        <template slot-scope="scope">
          <el-button size="mini" type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)"
            v-hasPermi="['base:train:edit']">修改</el-button>
          <el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)"
            v-hasPermi="['base:train:remove']">删除</el-button>
          <el-popconfirm @confirm="genSeat(scope.row)" title="生成座位将删除已有记录，确认生成座位？">
            <el-button slot="reference" size="mini" type="text" icon="el-icon-plus">生成座位</el-button>
          </el-popconfirm>
        </template>
      </el-table-column>
    </el-table>

    <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize"
      @pagination="getList" />

    <!-- 添加或修改列车管理对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="100px">
        <el-form-item label="车次编号" prop="code">
          <el-input v-model="form.code" placeholder="请输入车次编号" />
        </el-form-item>
        <el-form-item label="车次类型" prop="type">
          <el-select v-model="form.type" placeholder="请选择车次类型">
            <el-option v-for="dict in dict.type.type" :key="dict.value" :label="dict.label"
              :value="dict.value"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="始发站" prop="start">
          <el-select v-model="form.start" filterable placeholder="请选择始发站"
            @change="(value) => handleStationSelect(value, 'start')" style="width: 100%">
            <el-option v-for="item in stationOptions" :key="item.uniqueId" :label="item.label" :value="item.value"
              style="width: 300px">
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="始发站拼音" prop="startPinyin">
          <el-input v-model="form.startPinyin" :disabled="true" />
        </el-form-item>
        <el-form-item label="出发时间" prop="startTime">
          <el-time-picker clearable v-model="form.startTime" value-format="HH:mm:ss" placeholder="请选择出发时间">
          </el-time-picker>
        </el-form-item>
        <el-form-item label="终点站" prop="end">
          <el-select v-model="form.end" filterable placeholder="请选择终点站"
            @change="(value) => handleStationSelect(value, 'end')" style="width: 100%">
            <el-option v-for="item in stationOptions" :key="item.uniqueId" :label="item.label" :value="item.value"
              style="width: 300px">
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="终点站拼音" prop="endPinyin">
          <el-input v-model="form.endPinyin" :disabled="true" />
        </el-form-item>
        <el-form-item label="到站时间" prop="endTime">
          <el-time-picker clearable v-model="form.endTime" value-format="HH:mm:ss" placeholder="请选择到站时间">
          </el-time-picker>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>

    <!-- 导入对话框 -->
    <el-dialog :title="title" :visible.sync="importOpen" width="410px" append-to-body>
      <div class="import-tip" style="margin-bottom: 15px;">
        <p style="margin: 0 0 10px 0;">请按以下格式准备Excel文件：</p>
        <el-card class="box-card" shadow="never">
          <div class="text item">
            <p style="margin: 5px 0;">1. 车次编号（必填）：如 G1234</p>
            <p style="margin: 5px 0;">2. 车次类型（必填）：1-高铁，2-动车，3-普通列车</p>
            <p style="margin: 5px 0;">3. 始发站（必填）：如 北京西站</p>
            <p style="margin: 5px 0;">4. 始发站拼音（必填）：如 beijingxizhan</p>
            <p style="margin: 5px 0;">5. 出发时间（必填）：如 08:30:00</p>
            <p style="margin: 5px 0;">6. 终点站（必填）：如 上海虹桥站</p>
            <p style="margin: 5px 0;">7. 终点站拼音（必填）：如 shanghaihongqiaozhan</p>
            <p style="margin: 5px 0;">8. 到站时间（必填）：如 14:30:00</p>
          </div>
        </el-card>
        <div style="margin-top: 10px; display: flex; gap: 10px;">
          <el-link type="primary" @click="showExampleImage">
            查看Excel模板示例
          </el-link>
          <el-link type="primary" @click="handleDownloadTemplate">
            下载Excel模板
          </el-link>
        </div>
      </div>
      <el-upload ref="upload" class="upload-demo" :action="uploadExcelUrl" :headers="headers"
        :on-success="handleExcelSuccess" :on-error="handleExcelError" :auto-upload="false" :before-upload="beforeUpload"
        :limit="1" :on-exceed="handleExceed" :on-change="handleFileChange" accept=".xlsx, .xls">
        <el-button slot="trigger" size="small" type="primary">上传文件</el-button>
        <el-button style="margin-left: 10px;" size="small" type="success" @click="submitUpload"
          :disabled="!fileSelected">上传</el-button>
        <div slot="tip" class="el-upload__tip">只能上传xlsx/xls文件，且不超过5MB</div>
      </el-upload>
    </el-dialog>

    <!-- 添加示例图片对话框 -->
    <el-dialog title="Excel模板示例" :visible.sync="exampleImageVisible" width="830px" custom-class="zero-padding-dialog"
      :append-to-body="true">
      <table class="compact-table">
        <thead>
          <tr>
            <th>车次编号</th>
            <th>车次类型</th>
            <th>始发站</th>
            <th>始发站拼音</th>
            <th>出发时间</th>
            <th>终点站</th>
            <th>终点站拼音</th>
            <th>到站时间</th>
          </tr>
        </thead>
        <tbody>
          <tr>
            <td>G1234</td>
            <td>1</td>
            <td>北京西站</td>
            <td>beijingxizhan</td>
            <td>08:30:00</td>
            <td>上海虹桥站</td>
            <td>shanghaihongqiaozhan</td>
            <td>14:30:00</td>
          </tr>
        </tbody>
      </table>
    </el-dialog>

    <!-- 清空对话框 -->
    <el-dialog :title="title" :visible.sync="clearOpen" width="500px" append-to-body>
      <el-form ref="clearForm" :model="clearForm" :rules="clearRules" label-width="80px">
        <el-form-item label="密码" prop="password">
          <el-input v-model="clearForm.password" type="password" placeholder="请输入登录密码" show-password />
          <div style="color: #F56C6C; font-size: 12px; margin-top: 8px;">提示：清空操作将删除所有列车数据且不可恢复，请谨慎操作！</div>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitClearForm">确 定</el-button>
        <el-button @click="cancelClear">取 消</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import { getPlatformList } from "@/api/base/platform";
import { listTrain, getTrain, delTrain, addTrain, updateTrain, clearTrain } from "@/api/base/train";
import axios from "axios";

export default {
  name: "Train",
  dicts: ['type'],
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 选中数组
      codes: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 列车管理表格数据
      trainList: [],
      // 站点选项数据
      stationOptions: [],
      //图片显示
      exampleImageVisible: false,
      exampleData: [{
        code: 'G1234',
        type: '1',
        start: '北京西站',
        startPinyin: 'beijingxizhan',
        startTime: '08:30:00',
        end: '上海虹桥站',
        endPinyin: 'shanghaihongqiaozhan',
        endTime: '14:30:00'
      }],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 导入对话框
      importOpen: false,
      //上传地址
      uploadExcelUrl: process.env.VUE_APP_BASE_API + "/base/train/importExcel",
      //请求头
      headers: { 'Authorization': 'Bearer ' + this.$store.getters.token },
      //禁止上传按钮
      fileSelected: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {
        code: [
          { required: true, message: "车次编号不能为空", trigger: "blur" }
        ],
        type: [
          { required: true, message: "车次类型不能为空", trigger: "change" }
        ],
        start: [
          { required: true, message: "始发站不能为空", trigger: "blur" }
        ],
        startTime: [
          { required: true, message: "出发时间不能为空", trigger: "blur" }
        ],
        end: [
          { required: true, message: "终点站不能为空", trigger: "blur" }
        ],
        endTime: [
          { required: true, message: "到站时间不能为空", trigger: "blur" }
        ],
      },
      // 错误数据相关
      importErrorData: [],
      showImportError: false,
      // 清空对话框
      clearOpen: false,
      clearForm: {
        password: '',
      },
      clearRules: {
        password: [
          { required: true, message: "密码不能为空", trigger: "blur" }
        ],
      },
    };
  },
  created() {
    this.getList();
    this.getStationList();
  },
  methods: {
    /** 下载模板操作 */
    handleDownloadTemplate() {
      this.download('base/train/downloadTemplate', { ...this.queryParams }, `列车管理模板_${new Date().getTime()}.xlsx`);
    },
    // 显示示例图片
    showExampleImage() {
      this.exampleImageVisible = true;
    },
    // 远程搜索方法
    remoteMethod(query) {
      if (query !== '') {
        this.loading = true;
        getPlatformList().then(response => {
          this.stationOptions = response
            .filter(item => {
              return item.stationName.toLowerCase().includes(query.toLowerCase()) ||
                item.stationPinyin.toLowerCase().includes(query.toLowerCase()) ||
                item.stationInitials.toLowerCase().includes(query.toLowerCase());
            })
            .map((item, index) => ({
              value: item.stationName,
              label: `${item.stationName} ${item.stationPinyin}~${item.stationInitials.toLowerCase()}`,
              pinyin: item.stationPinyin,
              // 添加一个使用索引的唯一标识符以确保唯一性
              uniqueId: `${item.stationName}-${index}`
            }));
          this.loading = false;
        });
      } else {
        this.stationOptions = [];
      }
    },
    // 获取站点列表
    getStationList() {
      getPlatformList().then(response => {
        // 为每个站点选项添加唯一标识符
        this.stationOptions = response.map((item, index) => ({
          value: item.stationName,
          label: `${item.stationName} ${item.stationPinyin}~${item.stationInitials.toLowerCase()}`,
          pinyin: item.stationPinyin,
          stationName: item.stationName,
          // 添加一个使用索引的唯一标识符以确保唯一性
          uniqueId: `${item.stationName}-${index}`
        }));
      });
    },
    // 修改站点选择处理方法
    handleStationSelect(value, type) {
      const station = this.stationOptions.find(item => item.value === value);
      if (type === 'start') {
        this.form.start = value;
        this.form.startPinyin = station ? station.pinyin : '';
      } else if (type === 'end') {
        this.form.end = value;
        this.form.endPinyin = station ? station.pinyin : '';
      }
    },

    /** 查询列车管理列表 */
    getList() {
      this.loading = true;
      listTrain(this.queryParams).then(response => {
        this.trainList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        id: null,
        code: null,
        type: null,
        start: null,
        startPinyin: null,
        startTime: null,
        end: null,
        endPinyin: null,
        endTime: null,
        createTime: null,
        updateTime: null
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.id)
      this.codes= selection.map(item => item.code)
      this.single = selection.length !== 1
      this.multiple = !selection.length
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.open = true;
      this.title = "添加列车管理";
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      const id = row.id || this.ids
      getTrain(id).then(response => {
        this.form = response.data;
        this.open = true;
        this.title = "修改列车管理";
      });
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          if (this.form.id != null) {
            updateTrain(this.form).then(response => {
              this.$modal.msgSuccess("修改成功");
              this.open = false;
              this.getList();
            });
          } else {
            addTrain(this.form).then(response => {
              this.$modal.msgSuccess("新增成功");
              this.open = false;
              this.getList();
            });
          }
        }
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const ids = row.id || this.ids;
      const codes= row.code || this.codes;
      this.$modal.confirm('是否确认删除车次编号为"' + codes + '"的数据项？').then(function () {
        return delTrain(ids);
      }).then(() => {
        this.getList();
        this.$modal.msgSuccess("删除成功");
      }).catch(() => { });
    },
    /** 导入按钮操作 */
    handleImport() {
      this.importOpen = true;
      this.title = "数据导入";
    },
    submitUpload() {
      this.$refs.upload.submit();
      this.importOpen = false;
    },
    // 上传成功回调
    handleExcelSuccess(res, file) {
      console.log("Excel上传响应:", res); // 添加调试日志

      if (res.code === 200) {
        this.$modal.msgSuccess("上传Excel成功");
        this.importOpen = false;
        this.getList();
        // 清空错误数据
        this.importErrorData = [];
        this.showImportError = false;
      } else {
        // 处理唯一性校验失败的情况
        if (res.code === 500 && res.data) {
          // 保存错误数据
          this.importErrorData = Array.isArray(res.data) ? res.data : [];
          this.showImportError = this.importErrorData.length > 0;
          console.log("导入错误数据:", this.importErrorData); // 添加调试日志

          // 分析错误原因
          const duplicateCount = this.importErrorData.filter(item =>
            item.errorMsg && item.errorMsg.includes("已存在")).length;

          // 展示错误消息摘要
          let errorMsg = `导入失败：${this.importErrorData.length}条数据有误，`;
          if (duplicateCount > 0) {
            errorMsg += `其中${duplicateCount}条为车次编号重复，`;
          }
          errorMsg += `您可以"导出错误数据"或"复制到剪贴板"进行查看和处理`;

          this.$modal.msgError({
            message: errorMsg,
            type: 'error',
            duration: 5000,
            showClose: true
          });
        } else {
          this.$modal.msgError(res.msg || "上传失败");
        }
      }
      this.$refs.upload.clearFiles();
    },
    // 上传失败回调
    handleExcelError(err, file) {
      this.$modal.msgError("上传Excel失败，请重试");
      this.$refs.upload.clearFiles(); // 清空已上传的文件列表
    },
    // 上传前的文件校验
    beforeUpload(file) {
      const isExcel = file.type === 'application/vnd.ms-excel' || file.type === 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet';
      const isLt5M = file.size / 1024 / 1024 < 5;

      if (!isExcel) {
        this.$message.error('只能上传Excel文件!');
      }
      if (!isLt5M) {
        this.$message.error('上传文件大小不能超过5MB!');
      }
      return isExcel && isLt5M;
    },
    // 文件超出数量限制时的处理
    handleExceed(files, fileList) {
      this.$message.warning('只能上传一个文件');
    },
    handleFileChange(file, fileList) {
      this.fileSelected = fileList.length > 0;
    },
    /** 导出按钮操作 */
    handleExport() {
      // 创建一个新的对象，复制queryParams中的所有属性
      const exportParams = { ...this.queryParams };
      // 删除分页相关参数
      delete exportParams.pageNum;
      delete exportParams.pageSize;

      this.download('base/train/export', exportParams, `列车管理_${new Date().getTime()}.xlsx`)
    },
    genSeat(record) {
      this.loading = true;
      axios.get("/api2/business/admin/train/gen-seat/" + record.code).then((response) => {
        this.loading = false;
        const data = response.data;
        if (data.success) {
          this.$message({
            message: '生成成功',
            type: 'success'
          });
        } else {
          this.$message({
            message: '生成失败',
            type: 'error'
          });
        }
      });
    },
    // 导出错误数据
    handleExportErrorData() {
      this.$modal.loading("正在导出数据，请稍候...");

      // 确保每条错误记录都有ID
      const processedData = this.importErrorData.map(item => {
        // 创建新对象，避免直接修改原数据
        const newItem = { ...item };
        return newItem;
      });

      // 使用项目已有的下载功能替代XLSX库
      const formData = new FormData();
      formData.append("errorData", JSON.stringify(processedData));

      // 发送POST请求
      fetch(process.env.VUE_APP_BASE_API + "/base/train/exportErrorData", {
        method: "POST",
        body: formData,
        headers: {
          // 添加认证token
          "Authorization": "Bearer " + this.$store.getters.token
        }
      })
        .then(response => {
          if (response.ok) {
            return response.blob();
          }
          throw new Error("导出失败");
        })
        .then(blob => {
          const url = window.URL.createObjectURL(blob);
          const a = document.createElement("a");
          a.style.display = "none";
          a.href = url;
          a.download = "列车导入错误数据_" + new Date().getTime() + ".xlsx";
          document.body.appendChild(a);
          a.click();
          window.URL.revokeObjectURL(url);
          this.$modal.closeLoading();
        })
        .catch(error => {
          console.error("导出错误:", error);
          this.$modal.closeLoading();
          this.$modal.msgError("导出失败");
        });
    },
    // 复制错误数据到剪贴板
    handleCopyErrorData() {
      const textData = this.importErrorData.map(item => {
        return `车次编号: ${item.code || '-'}, 车次类型: ${item.type || 'G'}, ` +
          `始发站: ${item.start || '-'}, 始发站拼音: ${item.startPinyin || '-'}, 出发时间: ${item.startTime || '00:00:00'}, ` +
          `终点站: ${item.end || '-'}, 终点站拼音: ${item.endPinyin || '-'}, 到站时间: ${item.endTime || '00:00:00'}, ` +
          `错误原因: ${item.errorMsg || '未知错误'}`;
      }).join('\n');

      // 使用剪贴板API复制文本
      navigator.clipboard.writeText(textData).then(() => {
        this.$message({
          message: '错误数据已复制到剪贴板',
          type: 'success'
        });
      }).catch(err => {
        this.$message.error('复制失败，请手动复制');
        console.error('复制失败:', err);
      });
    },
    // 重新导入
    handleRetryImport() {
      this.handleImport(); // 打开导入对话框
    },
    // 清空按钮操作
    handleClear() {
      this.clearOpen = true;
      this.title = "清空列车数据";
    },
    submitClearForm() {
      this.$refs["clearForm"].validate(valid => {
        if (valid) {
          this.$modal.confirm('是否确认清空所有列车数据？').then(() => {
            return clearTrain({ password: this.clearForm.password });
          }).then(response => {
            if (response.code === 200) {
              this.$modal.msgSuccess("清空成功");
              this.clearOpen = false;
              // 重置导入错误相关的状态
              this.importErrorData = [];
              this.showImportError = false;
              // 重置密码表单
              this.resetClearForm();
              this.getList();
            } else {
              this.$modal.msgError(response.msg || "清空失败");
            }
          }).catch(error => {
            console.error("清空失败:", error);
            this.$modal.msgError("清空失败：" + (error.msg || "未知错误"));
          });
        }
      });
    },
    cancelClear() {
      this.clearOpen = false;
      this.resetClearForm();
    },
    resetClearForm() {
      this.clearForm = {
        password: ''
      };
      this.resetForm("clearForm");
    },
  }
};
</script>

<style scoped>
/* 导入错误对话框相关样式 */
.import-error-dialog ::v-deep .el-dialog__body {
  padding: 20px;
}

.error-dialog-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 15px;
}

.error-summary {
  display: flex;
  align-items: center;
  font-size: 15px;
}

.error-actions {
  display: flex;
  gap: 10px;
}

::v-deep .el-table .warning-row {
  background: #fdf5e6;
}

::v-deep .el-table .error-row {
  background: #fef0f0;
}

/* 紧凑型表格样式 */
.compact-table {
  width: 100%;
  border-collapse: collapse;
  border: 1px solid #EBEEF5;
  table-layout: fixed;
}

.compact-table th,
.compact-table td {
  border: 1px solid #EBEEF5;
  padding: 8px 6px;
  text-align: center;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.compact-table th {
  background-color: #F5F7FA;
  font-weight: bold;
  font-size: 13px;
}

/* 对话框样式 */
:deep(.zero-padding-dialog .el-dialog__body) {
  padding: 0 !important;
}

:deep(.zero-padding-dialog .el-dialog__header) {
  padding: 10px !important;
}
</style>
